<template>
  <a-page-header title="管理员管理" sub-title="管理员查看" />
  <a-table :dataSource="adminUserList" :columns="columns" rowKey="id" :loading="loading"> </a-table>
</template>

<script>
import { defineComponent, onMounted, ref } from "vue";
import { getAdminUser } from "../../utils/api";

export default defineComponent({
  setup() {
    const columns = [
      {
        title: "ID",
        dataIndex: "id",
      },
      {
        title: "用户名",
        dataIndex: "username",
      },
      {
        title: "密码",
        dataIndex: "password",
      },
    ];
    const loading = ref(false);
    const adminUserList = ref([]);

    const fetchAdminUserList = async () => {
      loading.value = true;
      let result = await getAdminUser();
      adminUserList.value = result.data.data;
      loading.value = false;
    };

    onMounted(() => {
      fetchAdminUserList();
    });

    return {
      columns,
      loading,
      adminUserList,
      fetchAdminUserList,
    };
  },
});
</script>
